<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!-- #include file = "../core.asp" -->
<%
var _system = $('system');
if (_system.read('submit') == '') {
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bestweb Content System - Login</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #FFFFFF;
}
body {
	background-color: #f3f3f3;
}
.k1 {border:#0854A1 1px solid; width:150px;}
-->
</style></head>

<body>
<form action="login.asp" method="post" name="login">
<br />
<br />
<table width="300" height="229" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="300" height="229" background="login_bg.gif"><br />
      <table border="0" align="center" cellpadding="3" cellspacing="0">
      <tr>
        <td>用户名：</td>
        <td><input name="name" type="text" class="k1" id="name" size="20" /></td>
      </tr>
      <tr>
        <td>密　码：</td>
        <td><input name="password" type="password" class="k1" id="password" size="20" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="submit" type="submit" id="submit" value="登录网站管理系统" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<br />
</form>
</body>
</html>
<%
}
else {
	var _name = _system.read('name');
	var _password = _system.read('password');
	
	var _database = $('database');
	_database.path = '../database/#database.mdb';
	var _md5 = $('md5');
	
	var _manager = _database.query('[Id], [Password]', '[Manager]', '[Name] = \'' + _name + '\'');
	
	if (_manager.length == 1) {
		if (_md5.encrypt(_password) == _manager[0].password) {
			_system.session('validate', 'true');
			
			var _sql = 'update [Manager] set [Ip] = \'' + _system.remote + '\', [Datetime] = \'' + _system.now() + '\' where Id = ' + _manager[0].id;
			_database.execute(_sql);
			
			_system.redirect('manage.asp');
		}
		else {
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bestweb Content System - Login</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #FFFFFF;
}
body {
	background-color: #f3f3f3;
}
.k1 {border:#0854A1 1px solid; width:150px;}
-->
</style>
</head>

<body>
<form action="login.asp" method="post" name="login">
<br />
<br />
<table width="300" height="229" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="300" height="229" background="login_bg.gif"><br />
      <table border="0" align="center" cellpadding="3" cellspacing="0">
      <tr>
        <td>用户名：</td>
        <td><input name="name" type="text" class="k1" id="name" size="20" value="<% =_name %>" /></td>
      </tr>
      <tr>
        <td>密　码：</td>
        <td><input name="password" type="password" class="k1" id="password" size="20" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="submit" type="submit" id="submit" value="登录网站管理系统" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<br />
</form>
</body>
</html>
<%
		}
	} 
	else {
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bestweb Content System - Login</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #FFFFFF;
}
body {
	background-color: #f3f3f3;
}
.k1 {border:#0854A1 1px solid; width:150px;}
-->
</style>
</head>

<body>
<script type="text/javascript">
	alert('用户名或密码错误！');
	history.go(-1);
</script>
</body>
</html>
<%
	}
}
%>